home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #11 / Amiga Plus CD - 2004 - No. 11.iso / AmiSoft / Text / print / HPDJ400Src.lha / transfer.c < prev   
C/C++ Source or Header  |  2004-05-25  |  4KB  |  106 lines

  1. /*
  2.  * Transfer routine for HP_Deskjet_400C
  3.  */
  4.  
  5. #include "global.h"
  6.  
  7. #define NUMCOLORCMD 7
  8.  
  9. void Transfer(struct PrtInfo *PInfo, ULONG y, UBYTE *colors[], UWORD RowSize, UWORD NumColorBufs)
  10. {
  11.         extern struct PrinterData *PD;
  12.         extern struct PrinterExtendedData *PED;
  13.  
  14.         static UBYTE bit_table[] = {128, 64, 32, 16, 8, 4, 2, 1};
  15.         UBYTE *dmatrix, Black, dvalue, threshold;
  16.         union colorEntry *ColorInt;
  17.         UWORD x, width, sx, *sxptr, shade;
  18.         UBYTE Yellow, Magenta, Cyan; 
  19.         UBYTE *bptr=NULL, *yptr=NULL, *mptr=NULL, *cptr=NULL;
  20.  
  21.         /* pre-compute */
  22.         /* printer non-specific, MUST DO FOR EVERY PRINTER */
  23.         x = PInfo->pi_xpos; /* get starting x position */
  24.         ColorInt = PInfo->pi_ColorInt; /* get ptr to color intensities */
  25.         sxptr = PInfo->pi_ScaleX;
  26.         width = PInfo->pi_width; /* get # of source pixels */
  27.         shade = PD->pd_Preferences.PrintShade;
  28.  
  29.         if (shade == SHADE_COLOR) {          /* Order CMY */
  30.           cptr = colors[0];
  31.           mptr = colors[1];
  32.           yptr = colors[2];
  33.         }
  34.         else
  35.            bptr = colors[0];
  36.        
  37.  
  38.         /* pre-compute threshold; are we thresholding? */
  39.  
  40.         if (threshold = PInfo->pi_threshold) { /* thresholding */
  41.                 dvalue = threshold ^ 15; /* yes, so pre-compute dither value */
  42.                 do { /* for all source pixels */
  43.                         /* pre-compute intensity value for Black */
  44.                         Black = ColorInt->colorByte[PCMBLACK];
  45.                         ColorInt++; /* bump ptr for next time */
  46.  
  47.                         sx = *sxptr++;
  48.  
  49.                         /* dither and render pixel */
  50.                         do { /* use this pixel 'sx' times */
  51.                                 /* if we should render Black */
  52.                                 if (Black > dvalue) {
  53.                                         /* set bit */
  54.                                         *(bptr + (x >> 3)) |= bit_table[x & 7];
  55.                                 }
  56.                                 ++x; /* done 1 more printer pixel */
  57.                         } while (--sx);
  58.                 } while (--width);
  59.         }
  60.         else { /* not thresholding, pre-compute ptr to dither matrix */
  61.              dmatrix = PInfo->pi_dmatrix + ((y & 3) << 2);
  62.              if (PD->pd_Preferences.PrintShade == SHADE_GREYSCALE)
  63.              {
  64.                 do { /* for all source pixels */
  65.                         /* pre-compute intensity value for Black */
  66.                         Black = ColorInt->colorByte[PCMBLACK];
  67.                         ColorInt++; /* bump ptr for next time */
  68.  
  69.                         sx = *sxptr++;
  70.  
  71.                         /* dither and render pixel */
  72.                         do { /* use this pixel 'sx' times */
  73.                                 /* if we should render Black */
  74.                                 if (Black > dmatrix[x & 3]) {
  75.                                         /* set bit */
  76.                                         *(bptr + (x >> 3)) |= bit_table[x & 7];
  77.                                 }
  78.                                 ++x; /* done 1 more printer pixel */
  79.                         } while (--sx);
  80.                 } while (--width);
  81.              }
  82.              else
  83.              { /* color - YMC only */
  84.                do {
  85.                     Yellow = ColorInt->colorByte[PCMYELLOW];
  86.                     Magenta = ColorInt->colorByte[PCMMAGENTA];
  87.                     Cyan = ColorInt->colorByte[PCMCYAN];
  88.                     ColorInt++;
  89.  
  90.                     sx = *sxptr++;
  91.  
  92.                     do {
  93.                          dvalue = dmatrix[x & 3];
  94.                          if (Yellow > dvalue)
  95.                             *(yptr + (x >> 3)) |= bit_table[x & 7];
  96.                          if (Magenta > dvalue)
  97.                             *(mptr + (x >> 3)) |= bit_table[x & 7];
  98.                          if (Cyan > dvalue)
  99.                             *(cptr + (x >> 3)) |= bit_table[x & 7];
  100.                          ++x;
  101.                     } while (--sx);
  102.                } while (--width);
  103.              } /* endif */
  104.          } /* endif */
  105. } /* end main */
  106.